import React, { Component, PureComponent } from 'react';
import {
  StyleSheet,
  View,
  Text,
  TouchableOpacity
} from 'react-native';
import { px2dp } from '@/styles';

/**
 * @author kanglang
 * @description 联系我们
 * @createDate 2020/8/17
 */
export default class CarDetails extends Component {
  constructor(props) {
    super(props);
    this.state = ({
    });
  }

    // 点击购买
    callUs = () => {
      const { click } = this.props;
      click && click();
    };

    formatePrice(number) {
      if (number) {
        return (number / 10000).toFixed(2);
      }
    }

    render() {
      const { originalPrice, btnText } = this.props;
      return (
        <View style={styles.footerWrap}>
          <View style={styles.leftWrap}>
            <Text style={styles.oneTip}>指导价:&nbsp;</Text>
            <Text style={styles.twoTip}>
              <Text style={styles.rmbTip}>¥</Text>
              {originalPrice && this.formatePrice(originalPrice)}
              <Text style={styles.wanTip}>万</Text>
            </Text>
          </View>
          <TouchableOpacity
            style={styles.callBtn}
            onPress={this.callUs}
          >
            <Text style={styles.callUs}>{btnText || '联系我们'}</Text>
          </TouchableOpacity>
        </View>
      );
    }
}

const styles = StyleSheet.create({
  footerWrap: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'space-between',
    backgroundColor: '#fff',
    height: px2dp(55) * 2,
    width: '100%',
    paddingLeft: px2dp(16) * 2,
    paddingRight: px2dp(16) * 2,
    borderTopColor: '#E6E6E5',
    borderTopWidth: px2dp(1),
    // position: 'absolute',
    // bottom:0
  },
  leftWrap: {
    flexDirection: 'row',
    alignItems: 'center'
  },
  oneTip: {
    color: '#343332',
    fontSize: px2dp(14) * 2
  },
  twoTip: {
    color: '#EA0505',
    fontSize: px2dp(21) * 2
  },
  rmbTip: {
    fontSize: px2dp(16) * 2
  },
  wanTip: {
    fontSize: px2dp(16) * 2
  },
  callBtn: {
    backgroundColor: '#BA914A',
    borderRadius: px2dp(4) * 2,
    paddingTop: px2dp(9) * 2,
    paddingBottom: px2dp(9) * 2,
    paddingLeft: px2dp(28) * 2,
    paddingRight: px2dp(28) * 2
  },
  callUs: {
    color: '#FFFFFF',
    fontSize: px2dp(16) * 2
  }

});
